<?php

// $Id: ci_normal_ci_form.class.php 1836 2009-09-09 12:56:57Z ogrebg $

require_once(TANGRA_MAIN_DIR.'form/guardable_form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/textarea/form_field_textarea.class.php');
require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');


require_once($WSC->get_site_inc_dir().'modules/form_field_fckeditor/form_field_fckeditor.class.php');


class VPage_Normal_Form extends Guardable_Form {
	function __construct($attributes) {
		parent::__construct('vpage', 'admin/modules/tangra_cms/vpt/normal/vpage_edit_normal.php');

		$f_title = new Form_Field_Textarea('title', true, 500);
		$f_title->add_potential_error('contains_html');
		$this->add_field($f_title);

		$f_content_length = $attributes['content']['params'];
		tangra_if_not_int_throw_e($f_content_length);
		$f_content = new Form_Field_FCKeditor('content', true, $f_content_length ? $f_content_length : 102400);
		$this->add_field($f_content);

		$f_meta_description = new Form_Field_Textarea('meta_description', false, 1000);
		$f_meta_description->add_potential_error('contains_html');
		$this->add_field($f_meta_description);
	}


	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_tpl_map_entry('content', 'modules/form_field_fckeditor_html_tpl_metallic/form_field_fckeditor.tpl');
		$html_gen->change_field_p_error_map_entry('title', 'contains_html', 'modules/tangra_cms/forms/_vpt/en/vpage_normal/field_error_contains_html_en.tpl');
		$html_gen->change_field_p_error_map_entry('meta_description', 'contains_html', 'modules/tangra_cms/forms/_vpt/en/vpage_normal/field_error_contains_html_en.tpl');

		printbr('<pre>');
		printbr(htmlentities($html_gen->get_static_html()));
		printbr('</pre>');
	}
}
